package com.cxlin.cwanandroid.model.repository

import com.cxlin.base.model.api.BaseRepository
import com.cxlin.base.model.api.Result
import com.cxlin.cwanandroid.model.api.WanRetrofitClient
import com.cxlin.cwanandroid.model.bean.ArticleList
import com.cxlin.cwanandroid.model.bean.Hot

/**
 *
 * @Author: chenxunlin
 * @Date: 2024/5/11 14:54
 */
class SearchRepository : BaseRepository() {

    suspend fun searchHot(page: Int, key: String): Result<ArticleList> {
        return safeApiCall(
            call = { executeResponse(WanRetrofitClient.service.searchHot(page, key)) },
            errorMessage = "网络错误"
        )
    }

    suspend fun getWebSites(): Result<List<Hot>> {
        return safeApiCall(
            call = { executeResponse(WanRetrofitClient.service.getWebsites()) },
            errorMessage = "网络错误"
        )
    }

    suspend fun getHotSearch(): Result<List<Hot>> {
        return safeApiCall(
            call = { executeResponse(WanRetrofitClient.service.getHot()) },
            errorMessage = "网络错误"
        )
    }

}